SPB Git
2.3 KB · 15 lines tsx
1import type { Metadata } from "next";2import { getLocale } from "@/lib/i18n/server";3import { t } from "@/lib/i18n";4import { openapi } from "@/lib/papers/openapi";5export const revalidate = 3600;6export async function generateMetadata(): Promise<Metadata> { const d = t(await getLocale()); return { title: d.api.title, alternates: { canonical: "/api/docs" } }; }7export default async function ApiDocs() {8  const locale = await getLocale(); const d = t(locale); const spec = openapi();9  return (<div className="container py-10 max-w-4xl"><h1 className="text-3xl sm:text-4xl">{d.api.title}</h1><p className="meta mt-2">{spec.info.description} · <a href="/api/v1/openapi.json" className="text-navy">openapi.json</a></p>10    <p className="text-sm text-fg-2 mt-3">{locale === "fr" ? "Lecture seule, sans authentification, CORS ouvert, limite de 120 requêtes par minute et par adresse. Les réponses sont en JSON ; les citations en BibTeX ou RIS." : "Read-only, no authentication, open CORS, limited to 120 requests per minute per address. Responses are JSON; citations are BibTeX or RIS."}</p>11    <div className="mt-8 space-y-4">{Object.entries(spec.paths).map(([path, ops]) => Object.entries(ops as Record<string, { summary: string; description?: string; parameters?: { name: string; in: string; description?: string; schema?: { type?: string; enum?: string[] } }[] }>).map(([method, op]) => <section key={method + path} className="card p-4"><h2 className="font-mono text-base"><span className="chip chip-navy uppercase mr-2">{method}</span>{path}</h2><p className="text-sm text-fg mt-2 font-medium">{op.summary}</p>{op.description && <p className="text-sm text-fg-2 mt-1">{op.description}</p>}{op.parameters?.length ? <ul className="mt-2 text-sm grid gap-1">{op.parameters.map((p) => <li key={p.name}><code className="text-navy">{p.name}</code> <span className="text-fg-3">({p.in}{p.schema?.type ? `, ${p.schema.type}` : ""}{p.schema?.enum ? `: ${p.schema.enum.join(" | ")}` : ""})</span>{p.description ? ` — ${p.description}` : ""}</li>)}</ul> : null}</section>))}</div>12    <h2 className="text-2xl mt-10 mb-3">OAI-PMH</h2><p className="text-sm text-fg-2"><code>/api/oai?verb=Identify</code> · <code>?verb=ListRecords&metadataPrefix=oai_dc</code> · <code>?verb=GetRecord&identifier=oai:wp.spboucher.ai:wp38&metadataPrefix=oai_dc</code> · <code>?verb=ListSets</code></p>13  </div>);14}15
Files · 734affbc3f56470ca2e43d159e14b200279bfbfc
Menu

Theme